#include <iostream>
#include <queue>
using namespace std;

const int kMaxN = 210;
const int kInf = 1e9;

int k[kMaxN], dis[kMaxN];

int BFS(int n, int a, int b) {
  queue<int> q;

  fill(dis, dis + n + 1, kInf);
  dis[a] = 0;
  q.emplace(a);
  while (!q.empty()) {
    int now = q.front();

    q.pop();
    if (now > k[now] && dis[now - k[now]] == kInf) {
      dis[now - k[now]] = dis[now] + 1;
      q.emplace(now - k[now]);
    }
    if (now + k[now] <= n && dis[now + k[now]] == kInf) {
      dis[now + k[now]] = dis[now] + 1;
      q.emplace(now + k[now]);
    }
  }
  return dis[b] == kInf ? -1 : dis[b];
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> k[i];
  }
  cout << BFS(n, a, b) << "\n";
  return 0;
}